package com.tuliyou.dto;
import com.tuliyou.entity.ScoreRank;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 分数段统计DTO（用于前后端交互，对应接口返回格式）
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ScoreRankDTO {

    private Long id;

    private Integer statYear;

    private String examType;

    private Integer score;

    private Integer rank;

    private Integer count;

    private Integer cumulativeCount;

    public static ScoreRankDTO fromScoreRank(ScoreRank scoreRank) {
        if (scoreRank == null) {
            return null;
        }
        return new ScoreRankDTO(
                scoreRank.getId(),
                scoreRank.getStatYear(),
                scoreRank.getExamType(),
                scoreRank.getScore(),
                scoreRank.getRank(),
                scoreRank.getCount(),
                scoreRank.getCumulativeCount()
        );
    }
}